#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    string str, pre;
    getline(cin, str);
    cin >> pre;
    vector<string> words;
    string word;
    for (int i = 0; i < str.size(); i++) {
        if (str[i] == ' ' || str[i]=='\'') {
            words.push_back(word);
            word = "";
        } else {
            word += str[i];
        }
    }
    words.push_back(word);
    for (int i = 0; i < words.size(); i++) {
        if (words[i].find(pre) == 0) {
            cout << words[i] << " ";
        }
    }
    cout << endl;
    return 0;
}